<template>
	<view class="container">
		<view class="status_bar">
			<view style="margin-left: 4%;" @tap="goBack()"><u-icon name="arrow-leftward" size='24' /></view>
			<view style="margin-left: -50upx; font-weight: bold;">群管理</view>
			<view></view>
			</u-icon>
		</view>
		<view style="display: flex;justify-content: space-around;align-items: center;">
			<view class="face-box">
				<u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
					:max-count="1" uploadIcon="plus" uploadIconColor="#bdbec0"></u-upload>
			</view>
		</view>
		<view class="shop-box">
			<view class="con-shop">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">群聊名称</view>
				</view>
				<view @click="gouqunname">
					<span style="padding-right: 10upx;">{{info.g_name}}</span>
					<uni-icons type="arrowright" size="18" color="#eaeaea"></uni-icons>
				</view>
			</view>
			<view class="con-shop" @tap="tohomo(info)">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">群成员</view>
				</view>
				<view>
					<span style="padding-right: 10upx;">{{originalArray.length}}/10000人</span>
					<uni-icons type="arrowright" size="18" color="#eaeaea"></uni-icons>
				</view>
			</view>
			<view class="con-shop" @tap="goqunma(info)">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">群二维码</view>
				</view>
				<view>

					<uni-icons type="arrowright" size="18" color="#eaeaea"></uni-icons>
				</view>
			</view>
			<view class="con-shop" @tap="gonotices()">
				<view style="display: flex;">

					<view style="margin-top: 10upx;">群公告</view>
				</view>
				<view>
					<span style="padding-right: 10upx;">{{info.g_notice}}</span>
					<uni-icons type="arrowright" size="18" color="#eaeaea"></uni-icons>
				</view>
			</view>
			<view class="con-shop" @tap="gobeizhu">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">群备注</view>
				</view>
				<view>
					<span style="padding-right: 10upx;">{{info.remark}} </span>
					<uni-icons type="arrowright" size="18" color="#eaeaea"></uni-icons>
				</view>
			</view>
			

			<view class="con-shop" @tap="recordShow = true">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">清空群聊天记录</view>
				</view>
				<view>

					<uni-icons type="arrowright" size="18" color="#eaeaea"></uni-icons>
				</view>
			</view>
			<u-gap height="6" bgColor="#f2f6fa"></u-gap>
			<view class="con-shop">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">消息置顶</view>
				</view>
				<view style="display: flex;">
					<u-switch v-model="value1" @change="change" size=20 activeColor="#1ea7dd"></u-switch>
				</view>
			</view>
			<view class="con-shop">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">消息免打扰</view>
				</view>
				<view style="display: flex;">
					<u-switch v-model="value2" @change="changexiaoxi" size=20 activeColor="#1ea7dd"></u-switch>
				</view>
			</view>
			<view class="con-shop">
				<view style="display: flex;">
					<view style="margin-top: 10upx;">我在本群昵称</view>
				</view>
				<view style="display: flex;">
					<u-switch v-model="value2" @change="changexiaoxi" size=20 activeColor="#1ea7dd"></u-switch>
				</view>
			</view>

			<u-gap height="6" bgColor="#f2f6fa"></u-gap>



		</view>
		<view class="bottom-box" v-if="group_info.g_owner_user_uid == userId" @tap="saveShow=true">解散群聊</view>
		<view class="bottom-box" v-else @tap="saveShows=true">退出群聊</view>
		<view>
			<u-calendar :show="showDate" @confirm="confirm" @close="close" color="#674fa3"></u-calendar>
		</view>
		<!-- 消息自毁弹框 -->
		<view style="position: relative;">
			<u-action-sheet :actions="list" :closeOnClickOverlay="true" :closeOnClickAction="true"
				@close="destructClose" :title="destructTitle" :show="destructShow" round=20
				@select="destructSelectClick" cancelText="取消">
			</u-action-sheet>
		</view>
		<!-- 朋友圈弹框 -->
		<view style="position: relative;">
			<u-action-sheet :actions="friendLSelectList" :closeOnClickOverlay="true" :closeOnClickAction="true"
				@close="friendLSelectClose" :title="destructTitle" :show="friendSelectShow" round=20
				@select="friendSelectClick" cancelText="取消">
			</u-action-sheet>
		</view>
		<!-- 清除聊天记录/缓存  @tap="recordShow=true"-->
		<u-popup :show="recordShow" @close="recordsClose" mode="center" :round="20">
			<view class="clear-record-box">
				<view class="clear-record-box-title">提示</view>
				<view class="clear-record-box-title1">{{type==1?'确定要清除所有聊天记录':'确定要清除所有缓存记录'}}？</view>
				<view class="clear-record-box-btn">
					<view class="clear-record-box-btn-left" @tap="recordsClose()">取消</view>
					<view class="clear-record-box-btn-right" @tap="recordsConFirm()">确认</view>
				</view>
			</view>
		</u-popup>
		<!-- 解散群聊-->
		<u-popup :show="saveShow" @close="saveShow = false" mode="center" :round="20">
			<view class="clear-record-box">
				<view class="clear-record-box-title">确认解散群聊</view>
				<view class="clear-record-box-btn">
					<view class="clear-record-box-btn-left" @tap="saveShow = false">取消</view>
					<view class="clear-record-box-btn-right" @tap="recordsConFirm1()">确认</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="saveShows" @close="saveShows = false" mode="center" :round="20">
			<view class="clear-record-box">
				<view class="clear-record-box-title">确认退出群聊</view>
				<view class="clear-record-box-btn">
					<view class="clear-record-box-btn-left" @tap="saveShows = false">取消</view>
					<view class="clear-record-box-btn-right" @tap="recordsConFirm2()">确认</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="showname" @close="recordsClose1" mode="center" :round="20">
			<view class="clear-record-box">
				<view class="clear-record-box-title" style="text-align: center;">修改群昵称</view>
				<view style="width: 60%;height: 40px;margin-left: 20%;margin-top: 20px;">
					<input :cursor-spacing="8" type="text" v-model="newnname" class="input" placeholder="请输入群昵称" />
				</view>
				<view class="clear-record-box-btn">
					<view class="clear-record-box-btn-left" @tap="recordsClose1()">取消</view>
					<view class="clear-record-box-btn-right" @tap="goname()">确认</view>
				</view>
			</view>
		</u-popup>

	</view>
</template>

<script>
	let disturbhashMap;
	let tophashMap;
	export default {
		data() {
			return {
				userId: uni.getStorageSync('userId') || '',
				startX: 0, // 触摸开始的X坐标
				endX: 0, // 触摸结束的X坐标
				threshold: 50, // 设置滑动多少距离后触发返回
				user: {},
				nickname: '',
				info: '',
				value23: true,
				fileList1: [], //头像上传
				text1: 'uView UI众多组件覆盖开发过程的各个需求，组件功能丰富，多端兼容。让您快速集成，开箱即用',
				showSex: false,
				columns: [
					[{
						label: '男',
						id: 2021
					}, {
						label: '女',
						id: 804
					}]
				],
				showDate: false,
				value1: false,
				value2: true,
				value21: true,
				value26: true,
				destructShow: false,
				destructTitle: '请选择',
				destructName: {
					name: '关闭'
				},
				list: [{
						name: '关闭'
					},
					{
						name: '1天'
					},
					{
						name: '2天'
					},
					{
						name: '3天'
					},
					{
						name: '4天'
					}
				],
				friendSelectShow: false,
				friendSelectName: {
					name: '全部'
				},
				friendLSelectList: [{
						name: '全部'
					},
					{
						name: '最近3天'
					},
					{
						name: '一个月'
					},
					{
						name: '半年'
					}
				],
				recordShow: false, //聊天记录
				type: 1,
				saveShow: false,
				saveShows: false,
				showname: false,
				newnname: "",

				group_info: {},
				originalArray: [],
			}
		},
		onLoad(option) {

			this.info = JSON.parse(option.groupId)
			console.log(this.info)
			if (this.info.image) {
				this.fileList1.push({
					'url': this.info.image
				})
			} else {
				this.fileList1.push({
					'url': `http://chat.zwsmcn.com:8090/chatfile/avatar_group/${this.info.g_id}.jpg`
				})
			}
			this.getDetail()
			this.getfriendlist()
		},
		onShow() {
			disturbhashMap = uni.getStorageSync('disturbhashMap' + uni.getStorageSync("user_uid"));
			tophashMap = uni.getStorageSync('tophashMap' + uni.getStorageSync("user_uid"));
			if (disturbhashMap) {
				disturbhashMap = new Map(JSON.parse(disturbhashMap));

				this.value2 = disturbhashMap.get(this.info.relatedId) ?? false;
			} else {
				disturbhashMap = new Map();
			}
			if (tophashMap) {
				tophashMap = new Map(JSON.parse(tophashMap));

				this.value1 = tophashMap.get(this.info.relatedId) ?? false;
			} else {
				tophashMap = new Map();
			}
		},
		methods: {
			
			gobeizhu() {
				this.toPage('/pages/contacts/transferOwner?groupId=' + JSON.stringify(this.info));
			},
			tohomo(info) {
				console.log(info)
				this.toPage('/pages/contacts/gagMember?groupId=' + JSON.stringify(info));
			},
			goqunma(info) {
				this.toPage('/pages/mine/account/qunCode?groupId=' + JSON.stringify(info));
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			},
			gonotices() {
				this.toPage('/pages/contacts/groupBlacklist?groupId=' + JSON.stringify(this.info));
			},

			gouqunname() {
				this.showname = true
			},
			change(e) {
				console.log('change', e);
				tophashMap.set(this.info.relatedId, e);
				uni.setStorageSync('tophashMap' + uni.getStorageSync("user_uid"), JSON.stringify(Array.from(
					tophashMap)))

				let where = '';
				let data = '';

				this.info.is_top = Number(e);

				data = `is_top = ${this.info.is_top}`
				where = `relatedId = '${this.info.relatedId}'`
				this.DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
					.then(res => {
						this.$forceUpdate();
						let pages = getCurrentPages();
						let prePage = pages[pages.length - 2]; // 上一页面
						prePage.$vm.updateInfo(JSON.stringify(this.info));
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			// 消息免打扰
			changexiaoxi(e) {
				console.log()

				let where = '';
				let data = '';

				disturbhashMap.set(this.info.user_uid, e);
				uni.setStorageSync('disturbhashMap' + uni.getStorageSync("user_uid"), JSON.stringify(Array.from(
					disturbhashMap)))
				this.info.is_mute = Number(e);


				data = `is_mute = ${this.info.is_mute}`
				where = `relatedId = '${this.info.relatedId}'`
				this.DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
					.then(res => {
						this.$forceUpdate();
						let pages = getCurrentPages();
						let prePage = pages[pages.length - 2]; // 上一页面
						prePage.$vm.updateInfo(JSON.stringify(this.info));
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			handlePickSex() {
				this.showSex = true
			},
			cancelSex() {
				this.showSex = false
			},
			confirmSex(e) {
				console.log('confirm', e)
				this.showSex = false
			},
			confirm(e) {
				console.log(e);
				this.showDate = false
			},
			close() {
				this.showDate = false
			},
			//消息自毁弹框事件
			destructClose() {
				this.destructShow = false
			},
			destructSelectClick(index) {
				this.destructName = index
			},
			//朋友圈弹框事件
			friendLSelectClose() {
				this.friendSelectShow = false
			},
			friendSelectClick(index) {
				this.friendSelectName = index
			},
			//清除聊天记录
			recordsOpen() {
				console.log('open');
				this.recordShow = false
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: '',
						message: ''
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					// this[`fileList${event.name}`].splice(fileListLen)
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					this.pictures.push(result)
					fileListLen++
				}


				console.log(this.pictures);
				console.log(this.fileList1);

			},
			uploadFilePromise(url) {
				console.log(url);
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: this.$api.baseUrl + '/api/v1/common/upload',
						header: {
							'content-type': 'multipart/form-data'
						},
						filePath: url,
						name: 'file',
						data: {
							file: url,
						},
						success: (res) => {
							console.log(res.data, "-==--=-=-觉得NSA加拿大境内时间");
							let img_item = JSON.parse(res.data);
							console.log(img_item.data.url);
							console.log(this.info.g_id);
							uni.request({
								// url: this.$api.baseUrl+'/penyouquan.json',
								url: this.$api.baseUrl + '/api/group/create/image',
								header: {
									'content-type': 'application/json'
								}, // this.$util.getHeader(),
								data: {
									image_url: img_item.data.url,
									g_id: this.info.g_id
								},
								method: 'POST',
								success: res => {
									console.log(res);
									if (res.data.code == 0) {
										this.$util.toast('添加成功')

										this.info.image = img_item.data.url
										let pages = getCurrentPages();
										let prePage = pages[pages.length - 2]; // 上一页面
										console.log(prePage);
										prePage.$vm.updateInfo(JSON.stringify(this.info));

									}

								},
								fail: res => {
									console.log(res);
								}

							})

						},
						fail: res => {
							console.log(res);
						}
					});
					// return;
					// let a = uni.uploadFile({
					// 	url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
					// 	filePath: url,
					// 	name: 'file',
					// 	formData: {
					// 		user: 'test'
					// 	},
					// 	success: (res) => {
					// 		console.log(res);

					// 		setTimeout(() => {
					// 			resolve(res.data.data)
					// 		}, 1000)
					// 	}
					// });
				})
			},
			// 获取群成员
			getfriendlist() {
				this.$util.loading('加载中')
				// const newDataObj = {
				// 	"user_uid": uni.getStorageSync('user_uid'),
				// };
				// const newDataJsonStr = JSON.stringify(newDataObj)

				let newData = {
					gid: this.info.g_id,
					// my_user_id:tthis.fromUserId,
				}
				const requestData = {
					"processorId": '1016',
					"jobDispatchId": '25',
					"actionId": '9',
					"newData": this.info.g_id,


				};
				const requestDataJsonStr = JSON.stringify(requestData);
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestDataJsonStr,
					method: 'POST',
					success: res => {
						uni.hideLoading()
						console.log(res);
						this.originalArray = JSON.parse(res.data.returnValue)
						console.log(this.originalArray, "3213-=-=-=-=")
					},
					fail: res => {
						console.log(res);
					}
				});
			},

			//解散群聊弹框
			recordsClose1() {
				this.showname = false
			},
			// 解散群聊
			recordsConFirm1() {

				const newDataObj = {
					"owner_uid": this.group_info
						.g_owner_user_uid, //uni.getStorageSync("user_uid"), // 群主uid(也就是解散的发起人)
					"owner_nickname": this.group_info.g_owner_name, // 群主昵称
					"g_id": this.info.g_id, // 将要被解散的群
					"g_name": this.info.g_name // 将要被解散的群名（v4.5 及以后版本，本参数已取消！）
				};
				const newDataJsonStr = JSON.stringify(newDataObj)
				var requestData = {
					"processorId": '1016',
					"jobDispatchId": '24',
					"actionId": '26',
					// "token": '23123',
					"newData": newDataJsonStr
				};
				const requestDataJsonStr = JSON.stringify(requestData);
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestDataJsonStr,
					method: 'POST',
					success: res => {
						console.log(res);
						if (res.data.success) {
							this.$util.toast('解散成功')
							this.saveShow = false

							let data = `del_flag = 1`
							let where = `relatedId = '${this.info.relatedId}'`
							// this.DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
							// 	.then(res => {
							// 		this.$forceUpdate();
							// 		uni.switchTab({
							// 			url: '/pages/message/index'
							// 		})
							// 	})
							// 	.catch(error => {
							// 		console.log("修改失败", error);
							// 	});


						}
					},
					fail: res => {
						console.log(res);
					}
				});
			},
			// 删除
			// 推出群聊
			recordsConFirm2() {
				let members = [{
					"user_uid": uni.getStorageSync("user_uid"),
					"nickname": uni.getStorageSync("nickname"),
					"g_id": this.info.g_id
				}]

				let values = members.map(item => [item.g_id, item.user_uid, item.nickname]);
				const newDataObj = {
					"del_opr_uid": uni.getStorageSync("user_uid"),
					"del_opr_nickname": uni.getStorageSync("nickname"), // 本次删除或退群的操作人昵称
					"gid": this.info.g_id, // 群 id 
					"members": JSON.stringify(values), // uni.getStorageSync("user_uid")
				};
				const newDataJsonStr = JSON.stringify(newDataObj)
				var requestData = {
					"processorId": '1016',
					"jobDispatchId": '24',
					"actionId": '23',
					// "token": '23123',
					"newData": newDataJsonStr
				};
				const requestDataJsonStr = JSON.stringify(requestData);
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestDataJsonStr,
					method: 'POST',
					success: res => {
						console.log(res);
						if (res.data.success) {
							this.$util.toast('退出成功')
							this.saveShow = false

							let data = `del_flag = 1`
							let where = `relatedId = '${this.info.relatedId}'`
							this.DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
								.then(res => {
									this.$forceUpdate();
									uni.switchTab({
										url: '/pages/message/index'
									})
								})
								.catch(error => {
									console.log("修改失败", error);
								});
						}
						// let arr = res.data.returnValue
						// if (arr == 1) {
						// 	this.$util.toast('退出成功')
						// } else {
						// 	this.$util.toast('退出失败')
						// }
						// this.saveShows = false
					},
					fail: res => {
						console.log(res);
					}
				});
			},
			// 修改群昵称
			goname() {
				const newDataObj = {
					"group_name": this.newnname, // 本次要修改成的新群名
					"gid": this.info.g_id, // 被修改的群 id
					"modify_by_uid": uni.getStorageSync("user_uid"), // 修改者的 uid
					"modify_by_nickname": this.nickname // 修改者的昵称
				};
				const newDataJsonStr = JSON.stringify(newDataObj)
				var requestData = {
					"processorId": '1016',
					"jobDispatchId": '24',
					"actionId": '8',
					// "token": '23123',
					"newData": newDataJsonStr
				};
				const requestDataJsonStr = JSON.stringify(requestData);
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestDataJsonStr,
					method: 'POST',
					success: res => {
						this.$util.toast('修改成功')
						this.info.g_name = this.newnname

						this.showname = false
						console.log(this.newnname);
						let pages = getCurrentPages();
						let prePage = pages[pages.length - 2]; // 上一页面
						console.log(prePage);
						prePage.$vm.updateInfo(JSON.stringify(this.info));
						console.log(this.newnname);

						let srcNickName = uni.getStorageSync('nickname') ?? '';
						let from_user_avatar = uni.getStorageSync('user_avatar_file_name') ?? '';;

						let at = [];
						let chat_type = 90;
						let typeu = 51;
						let dataContent = {};
						dataContent.changedByUid = uni.getStorageSync("user_uid");
						dataContent.nnewGroupName = this.newnname;
						dataContent.notificationContent =
							`"${uni.getStorageSync('nickname')}"修改群名为"${this.newnname}"`;
						dataContent.gid = this.info.g_id;
						dataContent.parentFp = '';
						console.log(this.info);
						console.log(dataContent);


						let p = uni.MBProtocalFactory.createGroupDataSimple(uni.IMSDK.getLoginInfo()
							.loginUserId,
							srcNickName, this.info.g_id, dataContent,
							typeu, at, chat_type, 0);
						console.log(p);
						p.time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
						p.gid = this.info.g_id;
						this.insertTableData(p)


					},
					fail: res => {
						console.log(res);
					}
				});
			},
			handleRecord(type) {
				console.log(this.type, 111)
				this.recordShow = true
				if (type == 1) {
					this.type = 1
				}
				if (type == 2) {
					this.type = 2
				}
			},
			recordsClose() {
				this.recordShow = false
				// console.log('close');
			},
			recordsConFirm() {

				this.recordShow = false
				let data = `del_flag = 1`;
				let where = `(relatedId = '${this.info.relatedId}')`
				// 修改表数据 DB.updateTableData(表名, 要修改的列名=修改后列值, 修改条件的列名, 修改条件的列值)
				this.DB.updateTableData("chat" + uni.getStorageSync("user_uid"), data, where)
					.then(res => {
						console.log(res);
						// uni.navigateBack({
						// 	delta: 2
						// });
					})
					.catch(error => {
						console.log("修改失败", error);
					});
			},
			logout() {
				
				uni.clearStorageSync()
				this.toPage('/pages/login')
			},
			showEdit() {
				this.groupName = this.group.name
				this.$refs.edit.open()
			},
			cancelEdit() {
				this.$refs.edit.close()
			},
			editAction() {
				if (this.$validate.isNull(this.groupName)) return
				uni.request({
					method: 'POST',
					url: this.$api.updateGroupName,
					data: {
						groupId: this.groupId,
						userId: this.userId,
						name: this.groupName
					},
					header: this.$util.getHeader(),
					success: res => {
						uni.hideLoading()
						this.$util.toast(res.data.msg)
						if (!res.data.code) {
							this.$refs.edit.close()
							this.group.name = this.groupName
							uni.setStorageSync('groupName', this.groupName)
						}
					},
					fail: res => {
						uni.hideLoading()
						this.$util.toast('保存失败')
					}
				})
			},
			// 上传头像
			uploadFace() {
				uni.chooseImage({
					count: 1,
					success: chooseRes => {
						const tempFilePaths = chooseRes.tempFilePaths
						tempFilePaths.forEach(temp => {
							uni.uploadFile({
								url: this.$api.uploadUserFace,
								filePath: temp,
								formData: {
									groupId: this.groupId,
									userId: this.userId
								},
								name: 'file',
								header: this.$util.getHeader(),
								success: uploadRes => {
									uni.hideLoading()
									if (uploadRes.data.code) return
									let data = JSON.parse(uploadRes.data)
									this.user.face = this.$api.staticPath + data.data
									uni.setStorageSync('userFace', this.user.face)
								}
							})
						})
					}
				})
			},
			// 获取信息
			getDetail() {

				let newData = {
					"gid": this.info.g_id,
					"my_user_id": uni.getStorageSync('user_uid')
				}
				const requestData = {
					"processorId": '1016',
					"jobDispatchId": '25',
					"actionId": '8',
					"newData": JSON.stringify(newData), // uni.getStorageSync('user_uid')
				};
				const requestDataJsonStr = JSON.stringify(requestData);
				uni.request({
					url: 'http://chat.zwsmcn.com:8090/rest_post',
					header: {
						'content-type': 'application/json'
					},
					data: requestDataJsonStr,
					method: 'POST',
					success: res => {
						console.log(res)
						console.log(JSON.parse(res.data.returnValue), "获取信息")
						if (res.data.success) {
							this.group_info = JSON.parse(res.data.returnValue);
						}
						console.log(this.indexList)
					},
					fail: res => {
						console.log(res);
					}
				});
			},
			getDetail1() {
				uni.request({
					url: this.$api.getUserInfo,
					data: {
						userId: this.userId
					},
					header: this.$util.getHeader(),
					success: res => {
						uni.hideLoading()
						this.user = res.data.data
						this.user.face = this.user.face ? this.$api.staticPath + this.user.face : ''
					},
					fail: err => {
						uni.hideLoading()
						this.$util.toast('获取失败')
					}
				})
			},

			// 新增表数据
			insertTableData(p) {
				console.log(p)
				let open = this.DB.isOpen();
				if (open) {
					let arr = []
					arr.push(p)
					// 如果需要根据p参数插入新数据，可以在这里正确处理p与arr的关系，例如arr.push(p)等操作

					arr.map(item => {
						console.log(item, 'arr-=-=-=-=-=arr-=-=-=-')

						let dataContent = JSON.parse(item.dataContent);

						let time = uni.MBUtils.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
						let gid = 0;
						let sm = 0;
						if (item.sm) {
							sm = item.sm;
						}
						let chat_type = dataContent.ty
						if (p.typeu == 45 || p.typeu == 47 || p.typeu == 50 || p.typeu == 49 || p.typeu ==
							48) {
							gid = JSON.parse(item.dataContent).t;

							chat_type = 90;
						} else if (p.typeu == 46) {
							gid = JSON.parse(item.dataContent).g_id;
							chat_type = 90;
						} else if (p.typeu == 51) {
							gid = JSON.parse(item.dataContent).gid;
							chat_type = 90;
						}
						if (p.typeu == 10) {
							gid = 0;
							chat_type = 90;
							item.from = JSON.parse(item.dataContent).user_uid;
						}

						let relatedId = '';
						if (!gid || gid == '0') {
							if (item.from == uni.getStorageSync('user_uid')) {
								relatedId = item.to;
							} else {
								relatedId = item.from;
							}
						} else {
							relatedId = gid;
						}
						if (p.typeu == 7) {
							relatedId = '0';
						}
						let disturbhashMap = uni.getStorageSync('disturbhashMap' + uni.getStorageSync("user_uid"));
						let tophashMap = uni.getStorageSync('tophashMap' + uni.getStorageSync("user_uid"));

						let is_top = 0;
						let is_mute = 0;
						if (disturbhashMap) {
							disturbhashMap = new Map(JSON.parse(disturbhashMap));
							is_mute = Number(disturbhashMap.get(relatedId)) ?? 0;
						}
						if (tophashMap) {
							tophashMap = new Map(JSON.parse(tophashMap));

							is_mute = Number(tophashMap.get(relatedId)) ?? 0;
						}

						console.log(relatedId);
						let sql =
							`'${item.type}', '${item.dataContent}', '${item.from}', '${item.to}', '${item.QoS}', '${item.typeu}', '${sm}', '${item.fp}', '0', '${time}', '${gid}',0,0, '${chat_type}','${relatedId}',${is_top},${is_mute}`;
						console.log(sql, "-=-=-=-=-=sas")
						let condition =
							'type, dataContent, from1, to1, QoS, typeu, sm, fp, retryCount, time,gid,is_collect,del_flag,chat_type,relatedId,is_top,is_mute';
						// 新增 DB.insertTableData(表名, 对应表头列的数据)


						console.log('insertTableData4')
						this.DB.insertTableData("chat" + uni.getStorageSync("user_uid"), sql, condition)
							.then(res => {
								console.log("新增数据成功");

							})
							.catch(error => {
								console.log("失败", error);
							});
					})


				} else {
					this.$util.toast("数据库未打开");
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100%;
		background: #f2f6fa;
	}

	.status_bar {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 50upx;
	}

	.status_bar,
	.head {
		background-color: #fff;
		height: 160upx;

		.face {
			width: 160upx;
			height: 160upx;
			border-radius: 10upx;
		}

		.info-name {
			font-size: 40upx;
			font-weight: bold;
		}

		.info-num {
			// width: 56upx;
			padding: 2upx 30upx;
			background: #f0f4f7;
			border-radius: 30upx;
			margin-top: 21upx;
		}

		.copybtns {
			color: #4457a4;
			margin-top: 21upx;
		}
	}

	.face-box {
		width: 200upx;
		height: 200upx;
		// background: #046bf2;
		border-radius: 50%;
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-top: 30upx;
	}

	.items {
		height: 100upx;
		padding: 0 30upx;
		background-color: #FFF;
		border-bottom: 2upx solid #F2F2F2;

		.label {
			color: #666;
			font-size: 32upx;
		}

		.value {
			color: #999;
			font-size: 30upx;
		}

		.face {
			width: 100upx;
			height: 100upx;
			border-radius: 10upx;
		}
	}

	.main-btn {
		color: red;
		height: 100upx;
		// padding: 0 30upx;
		margin-top: 100upx;
		background-color: #FFF;
	}

	.shop-box {
		// width: 92%;
		// margin-left: 4%;
		background-color: #fff;
		margin-top: 20upx;
		// border-radius: 20upx;
		//padding: 10upx 30upx;
		box-shadow: 0 0 40upx #d6e7f1; // 左
		box-shadow: 0 0 40upx #d6e7f1; // 右
		color: #2e2e2e;
		font-weight: 300;

		image {
			width: 70upx;
			height: 70upx;
			padding: 10upx 28upx 0upx 10upx;

		}
	}

	.con-shop {
		height: 100upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10upx 30upx;
		//border-bottom: 1upx solid #f7f7f7;

		span {
			padding-right: 10upx;
			color: #b5b5b5;
			font-size: 28upx;
		}

		.image-code {
			width: 42upx;
			height: 42upx;
			padding: 10upx 28upx 0upx 10upx;
		}
	}

	.bottom-box {
		// width: 92%;
		// margin-left: 4%;
		background-color: #fff;
		margin-top: 18upx;
		// border-radius: 20upx;
		padding: 30upx 30upx;
		box-shadow: 0 0 40upx #d6e7f1; // 左
		box-shadow: 0 0 40upx #d6e7f1; // 右
		//margin-bottom: 20upx;
		color: #d84e65;
		text-align: center;
	}

	.clear-record-box {
		border-radius: 30upx;
		padding: 30upx;

		.clear-record-box-title {
			padding: 10upx 20upx;
			font-size: 40upx;
		}

		.clear-record-box-title1 {
			padding: 20upx 0 30upx 20upx;
			font-size: 30upx;
			font-weight: 300;
		}

		.clear-record-box-btn {
			display: flex;
			// padding: 30upx 0 20upx 0;
			margin-left: 150upx;
			margin-top: 30upx;
		}

		.clear-record-box-btn-left {
			padding: 10upx 30upx;
		}

		.clear-record-box-btn-right {
			background: #000;
			color: #fff;
			padding: 10upx 40upx;
			margin-left: 30upx;
		}
	}
</style>